//
//  SliderPlot.h
//  Balance
//
//  Created by Calvin Kuo on 12-03-28.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CorePlot-CocoaTouch.h"
#import "BalanceModel.h"

@protocol SliderPlotDelegate;


@interface SliderPlot : NSObject<CPTPlotSpaceDelegate, CPTPlotDataSource, CPTScatterPlotDelegate, CPTScatterPlotDataSource>
{
@private
    CPTGraph *graph;
    CPTScatterPlot *linePlot; 
    CPTScatterPlot *fromIndicatorPlot; //date range selector: from-date
    CPTScatterPlot *toIndicatorPlot;  //date range selector: to-date
    CPTRangePlot *rangePlot;
    NSInteger selectedCoordination;
    NSInteger numberOfPeriods;
    BOOL fromIndicatorPlotSelected, toIndicatorPlotSelected;
    BOOL rangePlotMoved;
    NSInteger selectedFromCoordination;
    NSInteger selectedToCoordination;
    NSInteger currentCoordination;
    //NSInteger previousFromCoordination;
    //NSInteger previousToCoordination;
    NSInteger previousXPoint;
    //NSInteger distanceToIndicator;
    NSString *direction;
    Balance *startDateBal;
    Balance *endDateBal;
    NSInteger fromIndex;
    NSInteger toIndex;
    NSInteger previousFromIndex;
    NSInteger previousToIndex;
}

@property (nonatomic, retain) id<SliderPlotDelegate> delegate;
@property (nonatomic, retain) NSArray *monthKeys;
@property (nonatomic, retain) NSMutableDictionary *dailyBalances;
@property (nonatomic, retain) NSArray *dayKeys;

// Render the chart on the hosting view from the view controller with the default theme.
- (void)renderInLayer:(CPTGraphHostingView *)layerHostingView withTheme:(CPTTheme *)theme;

// Change the select line plot color.
- (void)applyIndicatorPlotColor;

@end


// Delegate to notify the view controller that the location of the line has changed.
@protocol SliderPlotDelegate <NSObject> 
@optional
- (void)linePlot:(SliderPlot *)plot indexLocation:(NSUInteger)index;
- (void)sliderPlot:(SliderPlot *)plot fromDate:(NSString *)fromDateString toDate:(NSString *)toDateString;



@end
